using System;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.Metadata.EntityElement;
using System.Data;
using Kingdee.BOS.ServiceHelper;
using System.Collections.Generic;
using Kingdee.BOS.Core.Attachment;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;

namespace QL.K3.SCM.SAL.CLIENT.BusinessPlugIn
{
    public class XiaoShouHeTong_fujian : AbstractDynamicFormPlugIn
    {


        /// <summary>
        /// 初始化，对其他界面传来的参数进行处理，对控件某些属性进行处理
        /// 这里不宜对数据DataModel进行处理
        /// </summary>
        /// <param name="e"></param>
        public override void OnInitialize(InitializeEventArgs e)
        {

        }








        public override void BarItemClick(BarItemClickEventArgs e)
        {
            if (e.BarItemKey == "tbFujian")
            {


                

                string yuandanid2 =  Convert.ToString( this.Model.DataObject["YuanDanFID"]);

             
               

                //ShowAttachmentList("102648", "102578");
                ShowAttachmentList( yuandanid2);

            }

           

        }

        





        /// <summary>
        /// 显示指定单的附件列表
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="srcBillIds"></param>
        private void ShowAttachmentList( string srcBillIds)
        {
            // 构建附件列表过滤条件
            AttachmentKey attachmentKey = new AttachmentKey();
            attachmentKey.BillType = this.View.BillBusinessInfo.GetForm().Id;
            attachmentKey.BillNo = string.Empty;
            attachmentKey.BillInterID = srcBillIds;
            // 设置为查看状态，禁止修改指定单的附件列表
            attachmentKey.OperationStatus = Kingdee.BOS.Core.Metadata.OperationStatus.VIEW;

            // 本案例不显示单据体附件，如下单据体行参数全部设置为空白
            attachmentKey.EntryKey = " ";
            attachmentKey.EntryInterID = "-1";
            attachmentKey.RowIndex = 0;

            // 列表过滤条件
            string filter = string.Format(@"FBILLTYPE='{0}' and FINTERID IN ('{1}') and FENTRYKEY='{2}' and FENTRYINTERID='{3}'",
                                attachmentKey.BillType,
                                string.Join("','", srcBillIds),
                                attachmentKey.EntryKey,
                                attachmentKey.EntryInterID);

            // 构建列表显示参数
            ListShowParameter listpara = new ListShowParameter();
            listpara.IsLookUp = false;
            listpara.CustomParams.Add(KeyConst.AttachmentKey, AttachmentKey.ConvertToString(attachmentKey));
            listpara.OpenStyle.ShowType = ShowType.Floating;
            listpara.Caption = "附件管理";
            listpara.FormId = FormIdConst.BOS_Attachment;
            listpara.MultiSelect = false;
            listpara.PageId = string.Format("{0}_{1}_F7", this.View.PageId, listpara.FormId);
            listpara.ListFilterParameter.Filter = filter;
            listpara.IsShowQuickFilter = false;

            this.View.ShowForm(listpara);
        }

       
    }


}
